package com.xin.di.uav.user.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xin.di.uav.mapper.TaskStatusLogMapper;
import com.xin.di.uav.user.order.po.TaskStatusLog;
import com.xin.di.uav.user.order.service.ITaskStatusLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 状态日志 服务实现类
 * </p>
 *
 * @author LTQ
 * @since 2023-04-18
 */
@RequiredArgsConstructor
@Service
public class TaskStatusLogServiceImpl extends ServiceImpl<TaskStatusLogMapper, TaskStatusLog> implements ITaskStatusLogService {

    @Autowired
    private TaskStatusLogMapper taskStatusLogMapper;


    @Override
    public void addTaskStatusLog(TaskStatusLog taskStatusLog) {
        taskStatusLogMapper.insert(taskStatusLog);
    }

    @Override
    public List<TaskStatusLog> selectListByTaskId(String taskId) {
        QueryWrapper<TaskStatusLog> taskStatusLogQueryWrapper = new QueryWrapper<>();
        taskStatusLogQueryWrapper.eq("task_id", taskId);
        taskStatusLogQueryWrapper.orderByDesc("update_time");
        taskStatusLogQueryWrapper.orderByAsc("status");
        List<TaskStatusLog> taskStatusLogs = taskStatusLogMapper.selectList(taskStatusLogQueryWrapper);
        return taskStatusLogs;
    }


}
